Release 10.1A: OpenEdge Getting Started:
Object-oriented Programming


Method scoping within the class hierarchy

A class can access all of the PUBLIC and PROTECTED methods of its super class as well as any methods that it defines. A super class that, in turn, inherits from another class inherits all its super class's PUBLIC and PROTECTED methods and so on to the root of the hierarchy. Therefore when a class inherits all of the PUBLIC and PROTECTED methods of its super class, it inherits all of the PUBLIC and PROTECTED methods available to the top of the class hierarchy.

While a subclass can access the PUBLIC and PROTECTED methods of its super class the reverse is not true. A super class cannot invoke any method in any of its subclasses unless the method is defined in the super class and overridden in the subclass. Methods defined only in a subclass are simply not visible to its super classes. Likewise, methods defined as PRIVATE in a super class are not visible to its subclasses. Since the access mode for a method must be specified as part of the method definition, a method must be explicitly defined as either PROTECTED or PUBLIC to be accessible to other classes in the hierarchy. A key benefit of the new syntax for classes is the PROTECTED access mode, which lets you define an interrelated set of method definitions accessible within a class hierarchy, but invisible to other classes or procedures.

Comparison with procedure-based programming

By comparison, internal procedures and functions are always public by default, which means that they can be executed from within a super procedure stack (through the RUN SUPER statement or SUPER built-in function), or from unrelated procedures. You can define internal procedures and functions as PRIVATE to restrict access to the defining procedure alone.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095